import $http from "@/services";
export default {
    state: {
        chartList: [],
        tableList: [],
    },
    reducers: {
        setFormat(state, { payload }) {
            console.log(payload)
            const formatPayload = {
                chartList: [
                    {
                        title: "迟到员工数量",
                        StyleData: { height: "400px" },
                        data: payload.lateBI
                    },
                    {
                        title: "早退员工数量",
                        StyleData: { height: "400px" },
                        data: payload.earlyBI
                    }
                ],
                tableList: [
                    {
                        title: "迟到详情",
                        StyleData: { height: "400px" },
                        data: payload.lateTable
                    },
                    {
                        title: "早退详情",
                        StyleData: { height: "400px" },
                        data: payload.earlyTable
                    }
                ]
            };
            return { ...state, ...formatPayload }
        }
    },
    effects: {
        *initFormat({ }, { put, call }) {
            const result = yield call($http.getAttendanceTable);
            if (result.code !== 0) return;
            yield put({
                type: "setFormat",
                payload: result.data
            });
        }
    },
}